home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- BorderStyle = 1 'Fixed Single
- Caption = "Dynamic Menu"
- ClientHeight = 1455
- ClientLeft = 2265
- ClientTop = 3045
- ClientWidth = 3165
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 1455
- ScaleWidth = 3165
- Begin VB.CommandButton CmdRemove
- Cancel = -1 'True
- Caption = "Remove"
- Height = 495
- Left = 1800
- TabIndex = 3
- Top = 720
- Width = 1215
- End
- Begin VB.CommandButton CmdAdd
- Caption = "Add"
- Default = -1 'True
- Height = 495
- Left = 240
- TabIndex = 2
- Top = 720
- Width = 1215
- End
- Begin VB.TextBox CaptionText
- Height = 285
- Left = 840
- TabIndex = 1
- Top = 240
- Width = 2175
- End
- Begin VB.Label Label1
- Caption = "Caption"
- Height = 255
- Left = 240
- TabIndex = 0
- Top = 240
- Width = 615
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuFileList
- Caption = "mnuFileList"
- Index = 0
- Visible = 0 'False
- End
- Begin VB.Menu mnuFileSep
- Caption = "-"
- Visible = 0 'False
- End
- Begin VB.Menu mnuFileExit
- Caption = "E&xit"
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private max_index As Integer
- Private Sub CmdAdd_Click()
- ' Load the new menu item.
- max_index = max_index + 1
- Load mnuFileList(max_index)
- mnuFileList(max_index).Caption = CaptionText.Text
- mnuFileList(max_index).Visible = True
- CaptionText.Text = ""
- ' Make the separator visible.
- mnuFileSep.Visible = True
- End Sub
- Private Sub CmdRemove_Click()
- Dim txt As String
- Dim ctl As Menu
- ' Find the menu item with this caption.
- txt = CaptionText.Text
- CaptionText.Text = ""
- For Each ctl In mnuFileList
- If ctl.Caption = txt Then Unload ctl
- Next ctl
- ' Make the separator visible.
- If mnuFileList.Count < 2 Then _
- mnuFileSep.Visible = False
- End Sub
- Private Sub mnuFileExit_Click()
- Unload Me
- End Sub
- Private Sub mnuFileList_Click(Index As Integer)
- MsgBox "Selected item" & Str$(Index)
- End Sub
-